class Solution(object):
    def countSegments(self, s):
        """
        :type s: str
        :rtype: int
        """
        s = s.split(' ')
        count = 0
        for i in range(len(s)):
            if s[i]:
                count += 1
        return count


data = Solution()
s = "Hello, my name is John"
print(data.countSegments(s))
